#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

class Solution {
public:
    int reverse(int x) {
        long n=0;
        while(x!=0){
            n = x%10 + n*10;
            x /= 10;
        }
        return n > INT_MAX || n < INT_MIN ? 0 : n;
    }
};

int main()
{
    Solution solution;
    solution.reverse(123);
    cout<<solution.reverse(123);
    cout<<endl<<INT_MAX;
    return 0;
}